<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="../css/setting.css"/>
</head>
<body class="white">
	<div class="mui-content" id="vueMain">
		<div class="forms">
		    	<div class="inputBox">
		    		<input type="text" name="" v-model="sendData.mobile" placeholder="请输入您的手机号" class="phoneIcon" />
		    	</div>
		    	<div class="inputBox vercode mui-clearfix">
		    		<input type="text" name="" v-model="sendData.code" class="codes" placeholder="验证码" />
		    		<button type="button" class="bexta-btn bexta-btn-red mui-btn getCode" data-loading-text="获取中">获取验证码</button>
		    	</div>
		    	<div class="inputBox">
		    		<input type="password" name="" v-model="sendData.password" placeholder="" class="pwdIcon1" />
		    	</div>
	    </div>	 
	    
	    <div class="mui-content-padded" style="margin-top: 20px;">
		    	<div class="procs">
		    		<div class="mui-input-row mui-checkbox mui-left">
				  <label>我已阅读并同意<span class="link" _id="protocol" _href="protocol.html" _title="影伴用户协议">《影伴用户协议》</span></label>
				  <input name="checkbox1" value="1" type="checkbox" v-if="active==1" checked />
				  <input name="checkbox1" value="1" type="checkbox" v-else />
				</div>
		    		
		    </div>
	   		<button type="button" class="bexta-btn bexta-btn-red mui-btn mui-btn-block " id="register"  >注册</button>
	   </div>
	</div>
<script src="../js/mui.js"></script>
<script src="../js/vue.min.js"></script>
<script src="../js/bexta.js"></script>
<script type="text/javascript">
	var apps;
	mui.init({
		beforeback:function(){
			if( plus.webview.currentWebview().opener().id == 'login' ){
				bexta.setStatus(true)
			}
		}
	})
	mui.plusReady(function () {
	   initVue();
	});
	function initVue(){
		apps = new Vue({
			el:'#vueMain',
			data:{
				active:0,
				sendData:{
					mobile:'',
					code:'',
					password:'',
					type:1
				}
			},
			mounted:function(){
				initEvent();
			}
		});
	}
	function initEvent(){
		document.querySelector('.getCode').addEventListener('tap', function(){
			if( check.phone(apps.sendData.mobile) ){
				var f = mui('.getCode').button('loading');
				bexta.ajax(api.send_msg, function(res){
					if( res.isError == 0 ){
						mui.toast(res.msg);
						bexta.countDown(90, function(m){
							if( m <=1  ){
								f.reset();
							}else{
								f.setText(m + '秒');
							}

						});
					}else{
						mui.toast(res.msg);
						f.reset();
					}
				},{data:apps.sendData},function(){
					f.reset();
				});
				
			}else{
				mui.toast('手机号有误');
			}
		});
		document.querySelector('.mui-checkbox').addEventListener('tap', function(){
			var input = this.querySelector('input');
			apps.active = input.checked ? 0 : 1;
		});
		document.querySelector('#register').addEventListener('tap', function(){
			if( apps.active != 1 ){
				mui.toast("请同意 影伴用户协议");
				return false;				
			}
			if( check.phone(apps.sendData.mobile) && check.code(apps.sendData.code) && apps.sendData.password.length >5 && apps.sendData.password.length <= 16  ){
				bexta.ajax(''+api.register, function(res){
//					bexta.setStorage('bexta_user', res);
					mui.toast("注册成功");
					mui.back();
				},{data:apps.sendData});
			}else{
				mui.toast("手机/验证密/密码有误");
			}
		});
	}
</script>
</body>
</html>